package cate.game.role.pvp.pointrace.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBPointRace;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "进行挑战 の 请求")
@OperationSetter(GDOperation.POINT_RACE_CHALLENGE)
public class PointRaceChallengeReq implements MsgInput {
    @NoteField(value = "对手主角uid")
    public String opponentUid;

    @NoteField(value = "跳过战斗")
    public boolean skip;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        EcResult<Void> r = game.pvp.pointRace.getHandler()
                .challenge(cc.getRole(), opponentUid, skip);
        if (!r.ok()) {
            game.notice.message(cc.getRole(), r.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBPointRace.CHALLENGE_REQ;
    }
}
